<style>
.layui-form-pane .layui-form-label{width:auto;}
.layui-form-item{margin-bottom: 0px;}
.layui-table-cell{padding:1px 2px;text-align:center;font-size:13px;line-height:19px;}
</style>
<div class="fixed-bar">
<form class="layui-form layui-form-pane fixed-bar-form" action="{:url()}" method="get" id="hisi-table-search">
	<div class="layui-form-item">
         <div class="layui-inline removeStat">
            <label class="layui-form-label">货仓</label>
            <div class="layui-input-inline">
                {:Form::select('storehouse', '0', $storehouseKV, '', '')}
            </div>
        </div>
		<div class="layui-inline">
		 	<label class="layui-form-label">订单号</label>
		     <div class="layui-input-inline">
		         <input type="text" name="client_ordernum" lay-verify="" placeholder="输入订单号" class="layui-input">
		     </div>
		 </div>
		{if env('env_site') == 'riwei' }
		<div class="layui-inline">
			<label class="layui-form-label">客户单号</label>
			<div class="layui-input-inline">
				<input type="text" name="ext_id" lay-verify="" placeholder="输入客户单号" class="layui-input">
			</div>
		</div>
		{/if}
		<div class="layui-inline">
			<label class="layui-form-label">物料名称</label>
		    <div class="layui-input-inline">
		        <input type="text" name="material_name" lay-verify="" placeholder="输入物料名称" class="layui-input">
		    </div>
		</div>
		
		<div class="layui-inline">
			<label class="layui-form-label">物料SKU</label>
		    <div class="layui-input-inline">
		        <input type="text" name="material_sku" lay-verify="" placeholder="输入材料SKU" class="layui-input">
		    </div>
		</div>
		
        <div class="layui-inline">
			<label class="layui-form-label">入库时间</label>
			<div class="layui-input-inline">
				<input type="text" name="create_date_range" readonly="" id="create_date_range" lay-verify="" placeholder="选择入库时间" class="layui-input">
			</div>
		</div>
        <div class="layui-inline">
			<label class="layui-form-label">占用日期</label>
			<div class="layui-input-inline">
				<input type="text" name="use_date_range" readonly="" id="use_date_range" lay-verify="" placeholder="物料占用时间" class="layui-input">
			</div>
		</div>
        <div class="layui-inline">
		 	<label class="layui-form-label">占用订单号</label>
		     <div class="layui-input-inline">
		         <input type="text" name="used_client_ordernum" lay-verify="" placeholder="占用订单号" class="layui-input">
		     </div>
		 </div>
        <div class="layui-inline removeStat">
            <label class="layui-form-label">来源工厂</label>
            <div class="layui-input-inline">
                {:Form::select('factory_id', '', $factoryKV, '', '')}
            </div>
        </div>
        <div class="layui-inline removeStat">
            <label class="layui-form-label">审核状态</label>
            <div class="layui-input-inline">
                {:Form::select('audit_status', '3', $audit_status, '', '')}
            </div>
        </div>
        <div class="layui-inline">
			<label class="layui-form-label">裁剪日期</label>
			<div class="layui-input-inline">
				<input type="text" name="cutting_time" readonly="" id="cutting_time" lay-verify="" placeholder="选择裁剪日期" class="layui-input">
			</div>
		</div>
        <div class="layui-inline">
			<label class="layui-form-label">录入人</label>
		    <div class="layui-input-inline">
		        <input type="text" name="create_user" lay-verify="" placeholder="入库人名称关键字" style="width:140px;" class="layui-input">
		    </div>
		</div>
		<div class="layui-inline">
			<button type="submit" class="layui-btn" lay-submit="" lay-filter="demo1">搜索</button>
            <button type="button" class="layui-btn layui-btn-primary hisi-export">导出</button>
		</div>
	</div>
</form>
</div>

<table id="dataTable"></table>

{include file="system@block/layui" /}

<script type="text/html" title="操作按钮模板" id="buttonTpl">
	{{# if(d.metre_left < d.metre){ }}
    	<a href="{:url('log')}?id={{ d.id }}" class="layui-btn layui-btn-xs layui-btn-normal hisi-iframe" hisi-data="{width: '800px', height: '600px'}" title="查看使用日志">使用日志</a>
	{{# } }}
</script>

<script type="text/html" id="auditStatusTpl">
    {{# if(d.audit_status == 0){ }}
		<span style="color:#FF9900">未审</span>
	{{# }else if(d.audit_status == 1){ }}
		已审
	{{# }else{ }}
		<span style="color:red">撤消</span>
	{{# } }}
</script>
<script type="text/html" id="createTimeTpl">
    <div><span title="{{layui.util.toDateString(d.create_time * 1000,'yyyy-MM-dd HH:mm') }}">{{layui.util.toDateString(d.create_time * 1000,'MM-dd HH:mm') }}</span></div>	
</script>
<script type="text/html" id="updateTimeTpl">
    <div>{{layui.util.toDateString(d.update_time * 1000,'yyyy-MM-dd HH:mm') }}</div>
</script>
<script type="text/html" id="toolbar">
	<div><span id="totaldata_tag"></span> &nbsp;
	&nbsp;&nbsp; &nbsp; <a data-href="{:url('checkOddments')}?val=1" class="layui-btn layui-btn-primary layui-btn-sm j-page-btns confirm layui-icon check">审核</a>&nbsp;&nbsp;
        <a data-href="{:url('checkOddments')}?val=2" class="layui-btn layui-btn-primary layui-btn-sm j-page-btns confirm layui-icon back">撤销</a>&nbsp;&nbsp;
	</div>
	</script>
</script>
<script type="text/javascript">
    layui.use([ 'jquery','table', 'tool', 'laydate'], function() {
        var $ = layui.jquery;
		var laydate = layui.laydate;
        var table = layui.table;
        laydate.render({
		    elem: '#create_date_range'
		    ,range: '~'
		    ,theme: 'molv'
		    ,mark: {'{:$today}':''}
	    	,change: function(value, date, endDate){
		    	$('#create_date_range').val(value);
            	$('#layui-laydate1').remove();//关闭面板
            }
		});
		laydate.render({
		    elem: '#cutting_time'
		    ,range: '~'
		    ,theme: 'molv'
		    ,mark: {'{:$today}':''}
	    	,change: function(value, date, endDate){
		    	$('#cutting_time').val(value);
            	$('#layui-laydate1').remove();//关闭面板
            }
		});
		laydate.render({
		    elem: '#use_date_range'
		    ,range: '~'
		    ,theme: 'molv'
		    ,mark: {'{:$today}':''}
	    	,change: function(value, date, endDate){
		    	$('#use_date_rage').val(value);
            	$('#layui-laydate1').remove();//关闭面板
            }
		});
        table.render({
            elem: '#dataTable'
            ,url: '{:url()}' //数据接口
            ,page: true //开启分页
            ,skin: 'row'
            ,even: true
            ,limit: 20
            ,limits: [20,50,100,150,200]
            ,text: {
                none : '暂无相关数据'
            }
            ,toolbar: '#toolbar'
            ,cellMinWidth: 80
            ,defaultToolbar: []
            ,cols: [[ //表头
                {type:'checkbox',width:50}
				,{field: 'field1', title: '裁剪日期',templet:function(d){ if(d.cutting_time>0){ 
					return"<span title="+layui.util.toDateString(d.cutting_time * 1000,'yyyy-MM-dd-HH:mm')+">"+layui.util.toDateString(d.cutting_time * 1000,'MM-dd HH:mm')+"</span>";
				}else{
						return '--';
				}}}
                ,{field: 'field1', title: '审核状态',templet: '#auditStatusTpl',width:70}
				,{field: 'client_ordernum', title: '订单号',templet:function(d){return '<span class="copy-item">'+d.client_ordernum+'</span>'}, width:100}
                ,{field: 'name', title: '物料名称',templet:function(d){return '<span class="copy-item">'+d.mInfo.name+'</span>'}, width:130}
				,{field: 'storehouse_name', title: '货仓'}
                ,{field: 'storeshelf_name', title: '货架'}
				,{field: 'metre', title: '余料米数'}
				,{field: 'use_metre', title: '已占用米数'}
				,{field: 'use_client_ordernum', title: '占用订单号'}
				,{field: 'field1', title: '占用时间',templet:function(d){ if(d.use_time>0){ 
					return"<span title="+layui.util.toDateString(d.use_time * 1000,'yyyy-MM-dd HH:mm')+">"+layui.util.toDateString(d.use_time * 1000,'MM-dd HH:mm')+"</span>";
				}else{
						return '';
				}}}
				,{field: 'metre_left', title: '剩余米数'}
                ,{field: 'material_sku', title: '物料SKU',templet:function(d){return '<span class="copy-item">'+d.mInfo.material_sku+'</span>'}, width:90}
                ,{field: 'color', title: '颜色',templet:function(d){return d.mInfo.color},width:60}
                ,{field: 'unit_price', title: '单价'}
                ,{field: 'amount', title: '总金额'}
				,{field: 'factory_name', title: '来源工厂', width:100}
				,{field: 'actionuser', title: '录入人'}
				,{field: 'create_time', title: '入库时间',templet: '#createTimeTpl', width:90}
                ,{title: '操作', templet: '#buttonTpl', fixed: 'right'}
            ]]
        });
    });
</script>